#include "MessagerApp.h"

#pragma comment(lib, "Messager.lib")
_declspec(dllimport) void SetHook();

CGameApp::CGameApp()
{
}

CGameApp::~CGameApp()
{
}

bool CGameApp::CreateWnd(LPCTSTR szWinTitle,HINSTANCE hInstance,HINSTANCE hPrevInstance,int nCmdShow)
{
	if(!hPrevInstance)
	{
		RegWndClass(hInstance);
	}

	m_hWnd=CreateWindow("WndCls",szWinTitle,WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX,CW_USEDEFAULT,0,CW_USEDEFAULT,0,NULL,NULL,hInstance,NULL);

	if(!m_hWnd)
	{
		return FALSE;
	}

	ShowWindow(m_hWnd,SW_HIDE);
	UpdateWindow(m_hWnd);
		
	SetHook();

	return TRUE;
}

ATOM CGameApp::RegWndClass(HINSTANCE hInstance)
{
	m_WndClassEx.cbSize=sizeof(WNDCLASSEX);
	m_WndClassEx.style=CS_HREDRAW | CS_VREDRAW;
	m_WndClassEx.lpfnWndProc=WndProc;
	m_WndClassEx.cbClsExtra=0;
	m_WndClassEx.cbWndExtra=0;
	m_WndClassEx.hInstance=hInstance;
	m_WndClassEx.hIcon=LoadIcon(NULL,IDI_APPLICATION);
	m_WndClassEx.hCursor=LoadCursor(NULL,IDC_ARROW);
	m_WndClassEx.hbrBackground=(HBRUSH)GetStockObject(BLACK_BRUSH);
	m_WndClassEx.lpszMenuName=NULL;
	m_WndClassEx.lpszClassName="WndCls";
	m_WndClassEx.hIconSm=LoadIcon(NULL,IDI_APPLICATION);

	return RegisterClassEx(&m_WndClassEx);
}

LRESULT CALLBACK CGameApp::WndProc(HWND hWnd,UINT message,WPARAM wParam,LPARAM lParam)
{
	switch(message)
	{
	case WM_DESTROY:
		PostQuitMessage(0);
		break;

	default:
		return DefWindowProc(hWnd,message,wParam,lParam);
	}
	return 0;
}